package com.hospital.spd.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.PageObjectUtil;
import com.hospital.spd.dao.GoodsUsedQtyMapper;
import com.hospital.spd.dao.SupplierDeliveryTimeSurveyMapper;
import com.hospital.spd.pojo.*;
import com.hospital.spd.service.PaginationService;
import com.hospital.spd.util.PaginationResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 97261
 */
@Service
public class PaginationServiceImpl implements PaginationService {


    @Autowired
    GoodsUsedQtyMapper goodsUsedQtyMapper;

    @Autowired
    SupplierDeliveryTimeSurveyMapper surveyMapper;

    /**
     * 分页显示品种使用量
     *
     * @param requestParams
     * @return
     */
    @Override
    public PaginationResultVO<GoodsUsedQtyDO> pageView(PaginationRequestParamsQuery requestParams) {

        PageHelper.startPage(requestParams.getPage(),requestParams.getLimit());
        List<GoodsUsedQtyDO> goodsList =
                goodsUsedQtyMapper.selectGoodsByPage(requestParams);
        PageInfo<GoodsUsedQtyDO> pageInfo = new PageInfo<>(goodsList);
        return (PaginationResultVO<GoodsUsedQtyDO>)PaginationResultUtils.paginationResult(pageInfo);
    }

    /**
     * 送货周期统计
     *
     * @param requestParams
     * @return
     */
    @Override
    public PaginationResultVO<SupplierDeliveryTimeSurveyDO> deliveryTime(DeliveryTimeRequestParamsQuery requestParams) {
        PageHelper.startPage(requestParams.getPage(),requestParams.getLimit());
        List<SupplierDeliveryTimeSurveyDO> goodsList =
                surveyMapper.selectByPage(requestParams);
        PageInfo<SupplierDeliveryTimeSurveyDO> pageInfo = new PageInfo<>(goodsList);
        return (PaginationResultVO<SupplierDeliveryTimeSurveyDO>)PaginationResultUtils.paginationResult(pageInfo);
    }


}
